<?php

declare(strict_types=1);
/**
 * This file is part of MoChat.
 * @link     https://mo.chat
 * @document https://mochat.wiki
 * @contact  group@mo.chat
 * @license  https://github.com/mochat-cloud/mochat/blob/master/LICENSE
 */
namespace MoChat\Plugin\ContactSop\Action\Sidebar;

use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\Middleware;
use Hyperf\HttpServer\Annotation\Middlewares;
use Hyperf\HttpServer\Annotation\RequestMapping;
use MoChat\App\Common\Middleware\SidebarAuthMiddleware;
use MoChat\Framework\Action\AbstractAction;
use MoChat\Plugin\ContactSop\Contract\ContactSopLogContract;

/**
 * Sop消息发送
 * @Controller
 */
class Send extends AbstractAction
{
    /**
     * @Inject
     * @var ContactSopLogContract
     */
    private $contactSopLogService;

    /**
     * 规则详情.
     * @Middlewares({
     *     @Middleware(SidebarAuthMiddleware::class)
     * })
     * @RequestMapping(path="/sidebar/contactSop/send", methods="POST")
     */
    public function handle(): array
    {
        $id = (int) $this->request->input('id');
        $this->contactSopLogService->updateContactSopLogById($id, [
            'status' => 1,
        ]);
        return [];
    }
}
